<!--  
Arkantos-web  Una aplicación web para llevar un registro de gastos.
Copyright (C) 2013 Nicolás Elias Rivera

This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of 
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.

You can contact me at: ynicolasy@gmail.com
-->
<html xmlns="http://www.w3.org/1999/xhtml"
	xmlns:ui="http://java.sun.com/jsf/facelets"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:s="http://jboss.com/products/seam/taglib"
    xmlns:f="http://java.sun.com/jsf/core"
    xmlns:a="http://richfaces.org/a4j"
    xmlns:rich="http://richfaces.org/rich">
    
	<head>
		<title>#{messages['registro.titulo']}</title>
		<link href="css/style.css" rel="stylesheet" type="text/css" />
	</head>

	<body id="bodyId">
	
	<div id="document">
	
	<div id="header">
		<div id="title">
			<h:outputText id="menuWelcomeId" value="#{messages['menu.usr']} #{credentials.username}" rendered="#{identity.loggedIn}"/>
		</div>
		<div id="status">
        		<s:link id="menuLoginId" view="/view/login.xhtml" value="#{messages['menu.inicio']}" rendered="#{not identity.loggedIn}" propagation="none"/>
        		<s:link id="menuLogoutId" view="/home.xhtml" action="#{identity.logout}" value="#{messages['menu.desc']}" rendered="#{identity.loggedIn}" propagation="none"/>
		</div>
	</div>

	<div id="container">
	
	<div id="sidebar">
		<ui:include src="menu.xhtml" />
	</div>

	<div id="content">
	
		<div class="section">
		
			<div class="entry errors">
				<h:messages style="color:red;margin:2px" />
			</div>
			
	    <h:form id="registroForm">
		
	    <rich:panel id="richPanelUno">
			
		<table border="1">
			<tr>
				<td>
					<h:outputLabel value="#{messages['registro.descripcion']}"/>
				</td>
				<td>
					<h:inputText id="descInput" label="#{messages['registro.descripcion']}" value="#{registro.descripcion}" required="true"/>
					<rich:spacer width="10"/>
					<!--  
					<rich:message id="descMessage" for="descInput" showDetail="true" errorLabelClass="error" style = "font-weight:bold;color:#FF0000"/>
					-->
				</td>
			</tr>
			<tr>
				<td>
					<h:outputLabel value="#{messages['registro.costo']}"/>
				</td>
				<td>
					<h:inputText id="costoInput" label="#{messages['registro.costo']}" value="#{registro.costo}" required="true"/>
					<rich:spacer width="10"/>
					<!--  
					<rich:message id="costoMessage" for="costoInput" showDetail="true" errorLabelClass="error" style = "font-weight:bold;color:#FF0000" />
					-->
				</td>
			</tr>
		</table>
			
		</rich:panel>
					
			<div class="buttonBox">
				<h:commandButton id="guardarButton" value="Guardar"
				action="#{registroAction.guardarRegistro(registro)}" disabled="false"
				rendered="true" />
				&#160;
				<s:button id="cancelarButton" value="Cancelar" view="/view/registroForm.xhtml"/>
			</div>

	    </h:form>
	    
		</div>
		
		<rich:spacer height="40px"  />
		
		<p>
			<rich:panel>
				<table>
				  <tr>
				    <td>
				    	<h:outputLabel value="#{messages['registro.total']}"/>
				    	<b>
				    		<h:outputLabel value="#{registroAction.total}"/>
				    	</b>
				    </td>
				  </tr>
				</table>
			</rich:panel>
		</p>
	
		<rich:spacer height="40px"  />
		
		<a:form id="listaForm">
	
		<rich:dataTable id="regDatatable" value="#{registroAction.totalRegistros}" var="r" border="1">
		  <h:column>
		    <f:facet name="header">#{messages['registro.descripcion']}</f:facet>
		    #{r.descripcion}
		  </h:column>
		  <h:column>
		    <f:facet name="header">#{messages['registro.costo']}</f:facet>
		    #{r.costo}
		  </h:column>
		  <h:column>
		    <f:facet name="header">#{messages['registro.fecha']}</f:facet>
		    <h:outputText value="#{r.fechaCreacion}" >
		    	<s:convertDateTime type="date" dateStyle="short" pattern="dd/MM/yyyy"/>
		    </h:outputText>
		  </h:column>
		  <h:column >
		  	<f:facet name="header">#{messages['global.acciones']}</f:facet>
		  	<h:commandLink id="eliminarLink" action="#{registroAction.eliminarRegistro(r)}" value="#{messages['global.eliminar']}" disabled="false" rendered="true" />
			<rich:message id="delMessage" for="eliminarLink" showDetail="true" errorLabelClass="error" style = "font-weight:bold;color:#FF0000" />
			<rich:spacer width="10" />
			<h:commandLink id="verLink" action="#{registroAction.verRegistro(r)}" value="#{messages['global.ver']}" disabled="false" rendered="true" />
		  </h:column>	
		 </rich:dataTable>
		 
		</a:form>
		
	</div>

</div>

<div id="footer">#{messages['titulo']}</div>

</div>
</body>
</html>